Skip to content

refactor(string): wrap RangeError throws in format in left-pad and right-pad#13401

Closed
Planeshifter wants to merge 2 commits into
developfrom
philipp/drift-string-2026-07-10
Closed

refactor(string): wrap RangeError throws in format in left-pad and right-pad#13401
Planeshifter wants to merge 2 commits into
developfrom
philipp/drift-string-2026-07-10

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request routes the two remaining plain-string throws in the @stdlib/string namespace through @stdlib/string/format. Namespace conformance for format-wrapped error construction was 92.9% (52/56 leaf packages) before this change.

@stdlib/string/left-pad

Wrap the RangeError on line 70 (empty third-argument guard) in format(...), matching the four other throws in lib/main.js and the 92.9% of @stdlib/string leaf packages that route every error message through @stdlib/string/format. format is already imported; the placeholder-free message renders byte-identical.

@stdlib/string/right-pad

Wrap the RangeError on line 70 (empty pad-string guard) in format(...), the sole remaining raw-string throw in lib/main.js. Import and message text are unchanged.

Related Issues

Does this pull request have any related issues?

None.

Questions

Any questions for reviewers of this pull request?

None.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Neither change alters observable behavior: format invoked on a placeholder-free string returns its input verbatim, so the thrown RangeError carries the same .message as before. Test suites assert error type only (not text), and no README, REPL, docs/types/test.ts, or example references the affected message strings.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This pull request was authored by Claude Code as part of an automated cross-package drift-detection routine. The routine surveys structural and semantic features across every leaf package in a namespace, identifies majority patterns, and normalizes mechanical outliers. The two throws normalized here were flagged and independently confirmed by three review passes (semantic classification, test/docs cross-reference, structural sanity) before commit. A human reviewer should confirm the interpretation.


@stdlib-js/reviewers


Generated by Claude Code

claude added 2 commits July 10, 2026 04:21
Wraps the empty-pad-string `RangeError` message in `format(...)` to match
the file's other four throws and align with the namespace convention (52
of 56 packages in `@stdlib/string` use `format` exclusively; the single
plain-string throw here was the only non-conforming call in the file).
Message text is unchanged.
Wraps the empty-pad-string `RangeError` message in `format(...)` to match
the file's other four throws and align with the namespace convention (52
of 56 packages in `@stdlib/string` use `format` exclusively; the single
plain-string throw here was the only non-conforming call in the file).
Message text is unchanged.
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
string/left-pad $\\color{green}130/130$
$\\color{green}+100.00\\%$
$\\color{green}15/15$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}130/130$
$\\color{green}+100.00\\%$
string/right-pad $\\color{green}130/130$
$\\color{green}+100.00\\%$
$\\color{green}15/15$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}130/130$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte

kgryte commented Jul 10, 2026

Copy link
Copy Markdown
Member

These changes are unnecessary as string interpolation is not required.

@kgryte kgryte closed this Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants